package cn.itsource.fallback;

import cn.itsource.constants.ErrorCode;
import cn.itsource.api.openfeign.IRuleApiToService;
import cn.itsource.pojo.ro.RuleRo;
import cn.itsource.result.JSONResult;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class RuleFallback implements FallbackFactory<IRuleApiToService> {

    @Override
    public IRuleApiToService create(Throwable cause) {
        return new IRuleApiToService() {
            @Override
            public JSONResult saveRule(RuleRo ruleRo) {
                return JSONResult.error(cause.getMessage()+ ErrorCode.SERVICE_OPENFEIGN_ERROR);
            }
        };
    }
}
